package com.example.wordpress;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageButton;
import android.app.Activity;
import android.content.Intent;

/**
 * 
 * @author Ignacio Javier Kovacs
 *
 */

public class Editor extends Activity {

	private Gallery gallery;
	private Database database;
	private EditorView postEditorView;
	private EditorCtrl postEditorCtrl;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		gallery = new Gallery();
		database = new Database(this);
		postEditorView = new EditorView(this);
		postEditorCtrl = new EditorCtrl(postEditorView, database, gallery);
		
		((ImageButton) findViewById(R.id.button_camera)).setOnClickListener(postEditorCtrl);
	}
	
	@Override
	protected void onPause() {
		postEditorCtrl.onPause();
		super.onPause();
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		return postEditorView.createOptionsMenu(menu);
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		postEditorCtrl.onActivityResult(requestCode, resultCode, data);
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		super.onOptionsItemSelected(item);
		return postEditorCtrl.onOptionsItemSelected(item);
	}
	
	@Override
	public void onBackPressed() {
		postEditorCtrl.onBackPressed();
	}
}
